package com.wwj.study.spring.formework.beans;

import com.wwj.study.spring.formework.aop.WAopConfig;
import com.wwj.study.spring.formework.core.WFactoryBean;
import com.wwj.study.spring.formework.aop.WAopProxy;

/**
 * @Author: wuweijun
 * @Date: 2018/12/1 21:54
 */
public class WBeanWrapper extends WFactoryBean {

    //还会用到  观察者  模式
    //1、支持事件响应，会有一个监听
    private WBeanPostProcessor postProcessor;

    //包装后的对象
    private Object wrapperInstance;
    //原始的通过反射new出来，要把包装起来，存下来
    private Object originalInstance;

    private WAopProxy aopProxy=new WAopProxy();

    public WBeanWrapper(Object instance) {
        //代理对象
        this.wrapperInstance = aopProxy.getProxyInstance(instance);
        this.originalInstance = instance;
    }

    public void setAopConfig(WAopConfig aopConfig) {
        aopProxy.setConfig(aopConfig);
    }

    public WBeanPostProcessor getPostProcessor() {
        return postProcessor;
    }

    public void setPostProcessor(WBeanPostProcessor postProcessor) {
        this.postProcessor = postProcessor;
    }

    public Object getWrapperInstance() {
        return wrapperInstance;
    }

    public void setWrapperInstance(Object wrapperInstance) {
        this.wrapperInstance = wrapperInstance;
    }

    public Object getOriginalInstance() {
        return originalInstance;
    }

    public void setOriginalInstance(Object originalInstance) {
        this.originalInstance = originalInstance;
    }
}
